//
//  WeiboTableView.m
//  BookRank
//
//  Created by wststar on 13-12-10.
//  Copyright (c) 2013年 wststar. All rights reserved.
//

#import "WeiboTableView.h"
#import "WeiboCell.h"
#import "WeiboView.h"
#import "WeiboModel.h"

@implementation WeiboTableView

- (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style
{
    self = [super initWithFrame:frame style:style];
    if (self) {
        // Initialization code
    }
    return self;
}

#pragma mark ---tableViewDatasource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.data.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *identifier = @"WeiboCell";
    WeiboCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[[WeiboCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier]autorelease];
    }
    WeiboModel * model = [self.data objectAtIndex:indexPath.row];
    cell.weiboModel = model;
    return cell;
}

#pragma mark --UITableViewDelegate
-(float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    WeiboModel * model = [self.data objectAtIndex:indexPath.row];
    float height = [WeiboView getWeiboViewHeight:model isRepost:NO isDetail:NO];
    height += 60;
    return height;
}


@end
